package com.zelix;

import java.util.*;

public class cv
        implements Enumeration {

    private Object a[];
    private int b;
    private int c;

    public cv(Object aobj[]) {
        if (aobj == null) {
            throw new IllegalArgumentException();
        } else {
            a = aobj;
            b = a.length;
            return;
        }
    }

    public static Enumeration a(Collection collection) {
        Object aobj[];
        int i;
        Iterator iterator;
        aobj = new Object[collection.size()];
        i = 0;
        iterator = collection.iterator();
        while (iterator.hasNext()) {
            aobj[i++] = iterator.next();
        }
        return new cv(aobj);
    }

    public final boolean hasMoreElements() {
        return c < b;
    }

    public final Object nextElement()
            throws NoSuchElementException {
        if (c >= b)
            throw new NoSuchElementException(getClass().getName());
        else
            return a[c++];
    }

    public void a(Comparator comparator) {
        if (c > 0) {
            throw new IllegalStateException();
        } else {
            Object aobj[] = a;
            a = (Object[]) a.clone();
            Arrays.sort(a, comparator);
            return;
        }
    }
}